package com.example.model;

import java.util.Queue;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.LinkedList;
import java.util.HashSet;

/**
 * 爬虫状态模型
 * 职责：维护爬虫运行时的状态信息
 * 属性：
 * - maxCount: 最大爬取数量
 * - urlQueue: URL待处理队列
 * - visitedUrls: 已访问URL集合
 * - crawledCount: 已爬取数量计数器
 * - allowedDomain: 允许爬取的域名
 */
public class CrawlerState {
    private Object maxCount;
    private Queue<UrlDepth> urlQueue;
    private Set<String> visitedUrls;
    private AtomicInteger crawledCount;
    private String allowedDomain;

    public CrawlerState() {
        this.urlQueue = new LinkedList<>();
        this.visitedUrls = new HashSet<>();
        this.crawledCount = new AtomicInteger(0);
    }

    // Getters and Setters
    public Object getMaxCount() {
        return maxCount;
    }

    public void setMaxCount(Object maxCount) {
        this.maxCount = maxCount;
    }

    public Queue<UrlDepth> getUrlQueue() {
        return urlQueue;
    }

    public Set<String> getVisitedUrls() {
        return visitedUrls;
    }

    public AtomicInteger getCrawledCount() {
        return crawledCount;
    }

    public String getAllowedDomain() {
        return allowedDomain;
    }

    public void setAllowedDomain(String allowedDomain) {
        this.allowedDomain = allowedDomain;
    }
} 